﻿Public Class FormOper
    Private WithEvents UcDigitalKeyboard1 As ucDigitalKeyboard
    Public usr As String
    Public source As String
    Public b_gt_sys_id As String
    Public ok_num_all As String
    Public oper_num_all As String
    Public current_procedure_No As Integer
    Dim objGtProcedureDetails As New clsGtProcedureDetails
    Private Sub FormOper_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        lblgt.Text = b_gt_sys_id
        setData()
    End Sub

    Private Sub setData()
        SpinEdit1.Value = Decimal.Parse(ok_num_all)
        SpinEdit2.Value = Decimal.Parse(oper_num_all)
        txt_operable_num.Value = SpinEdit1.Value - SpinEdit2.Value
    End Sub

    Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
        If Integer.Parse(txt_num.Value) > 0 Then
            If Integer.Parse(txt_num.Value) <= Integer.Parse(txt_operable_num.Value) Then
                Dim en As New entity_gt_procedure_details
                en.procedure_No = current_procedure_No
                en.oper_num = Integer.Parse(txt_num.Value)
                en.b_gt_sys_id = Integer.Parse(lblgt.Text)
                en.validity = "1"
                en.oper = usr
                Dim rtn As Integer = objGtProcedureDetails.save(en)
                If rtn <> -2 Then
                    MsgBox("入料成功")
                    If source.Equals("3gw") Then
                        CType(Owner, Form3GongWei).setDgvData()
                    End If
                    If source.Equals("6gw") Then
                        CType(Owner, Form6GongWei).setDgvData()
                    End If
                    If source.Equals("psqx0") Then
                        CType(Owner, FormOperPSQX0).setDgvOperData()
                        CType(Owner, FormOperPSQX0).SetDgvResultData()
                    End If
                    If source.Equals("check") Then
                        CType(Owner, FormCheck).setDgvOperData()
                        CType(Owner, FormCheck).SetDgvResultData1()
                    End If
                    Close()
                Else
                    MsgBox("入料失败")
                End If
            Else
                MsgBox("入料数量需 <= 可入料数量")
            End If
        Else
            MsgBox("入料数量需>0")
        End If
    End Sub

    Private Sub txt_num_MouseDown(sender As Object, e As MouseEventArgs) Handles txt_num.MouseDown
        UcDigitalKeyboard1 = New ucDigitalKeyboard
        If sender.MaskBox.Mask.EditMask = "d" Then
            UcDigitalKeyboard1.B_01 = False
        Else
            UcDigitalKeyboard1.B_01 = True
        End If

        If sender.GetType().Name.Equals("TextEdit") Then
            UcDigitalKeyboard1.B_02 = True
        Else
            UcDigitalKeyboard1.B_02 = False
        End If

        UcDigitalKeyboard1.Txt = sender

        Me.Controls.Add(UcDigitalKeyboard1)
        UcDigitalKeyboard1.Show()
        UcDigitalKeyboard1.BringToFront()
        UcDigitalKeyboard1.Focus()
    End Sub

End Class


Public Class entity_gt_procedure_details
    Public procedure_No As String   ' 工序
    Public oper_num As Integer   ' 操作数
    Public b_gt_sys_id As Integer  '关联ID
    Public validity As String
    Public oper As String   '操作员
End Class